package com.qidianit.mes.device.controller;


import com.qidianit.common.pojo.MESResult;
import com.qidianit.mes.device.service.DeviceLedgerService;
import com.qidianit.mes.pojo.DeviceLedger;
import com.qidianit.mes.pojo.DeviceTypeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/deviceLedger")
@CrossOrigin
public class DeviceLedgerController {

    @Autowired
    private DeviceLedgerService deviceLedgerService;
    @GetMapping("/list")
    public MESResult list(String deviceCode,String deviceName,
                          @RequestParam(defaultValue = "1")int page,
                          @RequestParam(defaultValue = "10")int limit) {
        MESResult mesResult = deviceLedgerService.list(deviceCode,deviceName,page,limit);
        return mesResult;
    }

    @PostMapping("/add")
    public MESResult add(@RequestBody DeviceLedger deviceLedger){
        return deviceLedgerService.add(deviceLedger);
    }
    @PostMapping("/edit")
    public MESResult edit(@RequestBody DeviceLedger deviceLedger){
        return deviceLedgerService.edit(deviceLedger);
    }
    @DeleteMapping("/delete")
    public MESResult delete(String id){
        return deviceLedgerService.delete(id);
    }
}
